package com.magnificent.atlantis.client.data.message.messages;

import com.magnificent.atlantis.client.data.configuration.ServerConfiguration;
import com.magnificent.atlantis.common.entity.messages.ServerMessage;
import com.magnificent.atlantis.common.entity.messages.ServerNewMeetingMessage;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import java.util.ArrayList;
import java.util.Date;

/**
 * User: Babanin
 * Date: 04.05.2009
 * Time: 22:33:20
 */
public class ClientNewMeetingMessage extends ClientMessage {

    protected Date date;
    private String meetingTitle;
    private String message;
    private int localTaskId;
    private ArrayList<Integer> invitedUsers;

    public ClientNewMeetingMessage() {
    }

    public ClientNewMeetingMessage(ServerNewMeetingMessage serverMessage, ServerConfiguration configuration) {
        super(serverMessage, configuration);

        this.date = serverMessage.getDate();
        this.meetingTitle = serverMessage.getTitle();
        this.message = serverMessage.getMessage();
        this.invitedUsers = serverMessage.getInvitedUsers();
    }

    @XmlAttribute()
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @XmlElement()
    public ArrayList<Integer> getInvitedUsers() {
        return invitedUsers;
    }

    public void setInvitedUsers(ArrayList<Integer> invitedUsers) {
        this.invitedUsers = invitedUsers;
    }

    public ServerMessage toServerMessage() {
        ServerNewMeetingMessage serverNewEventMessage = new ServerNewMeetingMessage();

        serverNewEventMessage.setDate(date);
        serverNewEventMessage.setInvitedUsers(invitedUsers);
        serverNewEventMessage.setMessage(message);
        serverNewEventMessage.setTitle(meetingTitle);
        serverNewEventMessage.setUserFromId(userFromId);

        return serverNewEventMessage;
    }

    public String getTitle() {
        return "New meeting \"" + meetingTitle + "\"";
    }

    @XmlAttribute()
    public String getMeetingTitle() {
        return meetingTitle;
    }

    public void setMeetingTitle(String meetingTitle) {
        this.meetingTitle = meetingTitle;
    }

    @XmlAttribute()
    public int getLocalTaskId() {
        return localTaskId;
    }

    public void setLocalTaskId(int localTaskId) {
        this.localTaskId = localTaskId;
    }

    @XmlAttribute()
    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public boolean isSystemMessage() {
        return true;
    }
}
